using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using ESecretary.WinUI;
using ESecretary.MyCommon;

namespace ESecretary.DataEntity
{
    [Serializable]
    public class ChatUserInfo
    {
        private int id;
        private string name;
        private string ip;
        private IPEndPoint endPoint;       
        public ChatUserInfo()
        {
        }

        public ChatUserInfo(int id, string name)
        {
            this.id = id;
            this.name = name;
        }

        public ChatUserInfo(int id, string name, IPEndPoint endPoint):this(id,name)
        {
            this.endPoint = endPoint;
        }

        public ChatUserInfo(int id, string name, string ip):this(id,name)
        {
            this.endPoint = new IPEndPoint(IPAddress.Parse(ip), MyConfig.LocalPort);
        }        

        public int ID
        {
            get
            {
                return id;
            }
            set
            {
                id = value;
            }
        }

        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
            }
        }

        public string IP
        {
            set
            {
                ip = value;
            }
        }

        public IPEndPoint EndPoint
        {
            get
            {
                return endPoint;
            }
            set
            {
                endPoint = value;
            }
        }
       
     
        public override bool Equals(object obj)
        {
            ChatUserInfo user = (ChatUserInfo)obj;
            if (user.id == this.id)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public override int GetHashCode()
        {
            return this.id;
        }      
    }
}
